<?php

/**
 * Base data holder class for framework
 * 
 * PHP version 5
 * 
 * @category  Framework
 * @package   Abacus11_Framework
 * @author    Philippe Jausions <jausions@php.net>
 * @copyright 2008 11abacus / Philippe Jausions
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD
 * @link      http://pear.11abacus.com/package/Abacus11_Framework
 */
class Abacus11_Framework_DataHolder extends ArrayObject 
{    
    /**
     * Property setter
     *
     * @param string $name  Property name
     * @param mixed  $value New property value
     * 
     * @return void
     *
    public function __set($name, $value)
    {
        $this->offsetSet($name, $value);
    }
    
    /**
     * Property getter
     *
     * @param string $name Property name
     * 
     * @return mixed
     *
    public function __get($name)
    {
        return $this->offsetGet($name);
    }
    */
    
    /**
     * Property getter
     *
     * Implements ArrayAccess::offsetGet()
     *
     * @param string $name Property name
     * 
     * @return mixed
     */
    public function offsetGet($name)
    {
        if ($this->offsetExists($name)) {
            return parent::offsetGet($name);
        }
        throw new Abacus11_Framework_Exception_NotFound('"'.$name
                       .'" could not be found', Abacus11_Framework::SCOPE_DATA);
    }
    
    /**
     * Merges data with current data and return new data holder
     *
     * @param array $data Array-like data
     * 
     * @return Abacus11_Framework_DataHolder
     */
    public function merge($data)
    {
        return new self(array_merge($this, $data));
    }
}

?>